找传奇、传世资源到传世资源站!

USBHID通信

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

USBHID通信
from clipboard

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace USBHIDControl{ public partial class Form1 : Form { USBHID usbHID = null; public Form1() { InitializeComponent(); usbHID = new USBHID(); foreach (string device in usbHID.GetDeviceList()) list_UsbHID.Items.Add(device); usbHID.DataReceived = usbHID_DataReceived; usbHID.DeviceRemoved = usbHID_DeviceRemoved; } void usbHID_DeviceRemoved(object sender, EventArgs e) { report myRP = (report)e; if (InvokeRequired) { Invoke(new EventHandler(usbHID_DeviceRemoved), new object[] { sender, e }); } else { tb_information.Text = "设备连接"; } } void usbHID_DataReceived(object sender, EventArgs e) { report myRP = (report)e; if (InvokeRequired) { Invoke(new EventHandler(usbHID_DataReceived), new object[] { sender, e }); } else { tb_information.Text = "\r\n" USBHID.ByteToHexString(myRP.reportBuff); } } /// <summary> /// open USB HID /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_connect_Click(object sender, EventArgs e) { if (list_UsbHID.SelectedItem == null) { tb_information.Text = "\r\n vendorID和productID不能为空"; return; } if (usbHID.OpenUSBHid(list_UsbHID.SelectedItem.ToString())) tb_information.Text = "\r\n open success"; else tb_information.Text = "\r\n open fail"; } private void btn_send_Click(object sender, EventArgs e) { tb_information.Text ="\r\n w: " usbHID.WriteUSBHID(tb_send.Text); } private void btn_clear_Click(object sender, EventArgs e) { tb_information.Text = ""; } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复